<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 自定义构造函数
        function Person(name,age){
            this.name = name;
            this.age = age;
        }
        // 手动创建一个new关键字
        function mynew(name ,age){
            var obj = {};
            var res = Person.call(obj,name,age);
            obj.__protot__ = Person.prototype;
            if (typeof res == "nudefined"){
                return obj;
            } else {
                return res;
            }
        }

        var obj2 = mynew("张三",22);
        console.log(obj2);

    </script>
</body>
</html>